package com.swak.doc;

import java.util.List;

import com.swak.annotation.ApiDoc;
import com.swak.utils.Lists;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * Api 文档
 *
 * @author: lifeng
 * @date: 2020/3/29 11:02
 */
@Data
@Accessors(chain = true)
public class Api {
	private String module;
	private String name;
	private String desc;
	private List<ApiMethod> methods;

	public Api addApiMethod(ApiMethod method) {
		if (methods == null) {
			methods = Lists.newArrayList();
		}
		methods.add(method);
		return this;
	}

	public static Api of(ApiDoc doc) {
		if (doc != null) {
			return new Api().setModule(doc.module()).setName(doc.function()).setDesc(doc.describe());
		}
		return null;
	}
}
